/*
 *
 *
 */

#ifndef GKT_CARD_H
#define GKT_CARD_H

#include "gkt_rfid.h"

#ifdef __cplusplus
extern "C" {
#endif

enum {
	GKT_CARD_STANDBY_NONE = 0,
	GKT_CARD_STANDBY_LPCD,
	GKT_CARD_STANDBY_POWEROFF,
	GKT_CARD_STANDBY_MAX
};

enum {
	GKT_CARD_DETECTED = 0,
	GKT_CARD_EVENT_MAX
};

#if defined(GKT_CONFIG_CARD_HEADER_ENABLE) && GKT_CONFIG_CARD_HEADER_ENABLE
enum {
	GKT_CARD_HEADER_TYPE_ENROLL,
	GKT_CARD_HEADER_TYPE_DEALER_LOGO,
	GKT_CARD_HEADER_TYPE_FACTORY_INSPECTION,
	GKT_CARD_HEADER_TYPE_AGING_TEST,
	GKT_CARD_HEADER_TYPE_CUSTOMER_CONFIG,
	GKT_CARD_HEADER_TYPE_RESERVED=0xff,
};
#endif

typedef struct _gkt_card_info {
	gkt_rfid_info_s	base;
	const uint8_t	*header;
} gkt_card_info_s;

#if defined(GKT_CONFIG_RFID_ENABLE) && GKT_CONFIG_RFID_ENABLE
int gkt_card_init(void);
void gkt_card_mask(int masked, uint32_t flags);
void gkt_card_calibrate(void);
uint32_t gkt_card_describe_fetch(gkt_rfid_info_s *rfid_info);
int gkt_card_get_current_info(uint32_t *data);
int gkt_card_standby_mode(uint32_t mode);
void gkt_card_open_keypad_trim(void);
void gkt_detect_card(void);
uint8_t gkt_card_task_status(void);
#if defined(GKT_CONFIG_RFID_QUERY_MODE_ENABLE) && GKT_CONFIG_RFID_QUERY_MODE_ENABLE
void gkt_card_polling_control(uint8_t status);
#endif

#if defined(GKT_CONFIG_CARD_HEADER_ENABLE) && GKT_CONFIG_CARD_HEADER_ENABLE
void gkt_card_package_header(uint8_t header_type, uint8_t *s_card_header_buffer);
int gkt_card_encryption(uint8_t *card_id, uint8_t *header_buf);	
int gkt_card_encryption_clear(uint8_t *card_id);
#endif

#if defined(GKT_CONFIG_WINDOW_USED_SPECIFIC_ENCRYPTION_CARD)	\
	&& GKT_CONFIG_WINDOW_USED_SPECIFIC_ENCRYPTION_CARD	\
	|| defined(GKT_CONFIG_WINDOW_USED_SPECIFIC_ENCRYPTION_CARD_1)	\
	&& GKT_CONFIG_WINDOW_USED_SPECIFIC_ENCRYPTION_CARD_1
int gkt_card_read_specific_encryption(uint8_t *card_id);
#endif

#else
#define gkt_card_mask(masked, flags)	do {} while (0)
#define gkt_card_calibrate()	do {} while (0)
#endif

#ifdef __cplusplus
}
#endif

#endif	/* GKT_CARD_H */

